package com.gitee.swsk33.websocketdemo.encoder;


import com.alibaba.fastjson2.JSON;
import com.gitee.swsk33.websocketdemo.dataobject.User;
import jakarta.websocket.Encoder;
import jakarta.websocket.EndpointConfig;

/**
 * 自定义编码器，用于发送User对象给客户端
 */
public class UserWebSocketEncoder implements Encoder.Text<User> {

	@Override
	public String encode(User user) {
		return JSON.toJSONString(user);
	}

	@Override
	public void init(EndpointConfig endpointConfig) {
	}

	@Override
	public void destroy() {
	}

}